<?php
class Form_ProfileSubForm extends Zend_Form_SubForm 
{
   /**
    * init() routine called when Zend_Form objects are created.
    * It make sense to define form elements in this method.
    * 
    * @see    http://framework.zend.com/manual/en/zend.form.html
    * @return void
    */ 
    public function init()
    {
    	 $nickname = new Zend_Form_Element_Text('nickname');
         $nickname->setLabel('Nickname:')
                  ->setAttrib('class', 'field')
                  ->setAttrib('onkeyup','checkForRange(this, 4, 50);')
                  ->setAttrib('onclick','checkForRange(this, 4, 50);')
                  ->setDescription('msgNickname')
                  ->setRequired(true)
                  ->addValidator('StringLength', true, array('min' => '4', 'max' => '50'))
                  ->setDecorators(array(
                        array('ViewHelper', array('helper'=>'formText')),
                        array('Label', array('separator'=>' ', 'class'=>'gray labelfield')),
                        array('Errors'),
                        array('Description', array('tag' => 'span', 'class' => 'hint')),
                        array('HtmlTag', array('tag' => 'li', 
                                               'class' => 'element-group'
                                               ))
                  ));
         
         $fullname = new Zend_Form_Element_Text('fullname');
         $fullname->setLabel('fullname')
                  ->setAttrib('class', 'field profileFull')
                  ->setAttrib('onkeyup','checkForRange(this, 4, 40);')
                  ->setAttrib('onclick','checkForRange(this, 4, 40);')
                  ->setDescription('msgFullname')
                  ->setRequired(true)
                  ->addValidator('StringLength', true, array('min' => '4', 'max' => '40'))
                  ->setDecorators(array(
                        array('ViewHelper', array('helper'=>'formText')),
                        array('Label', array('separator'=>' ', 'class'=>'gray labelfield')),
                        array('Errors'),
                        array('Description', array('tag' => 'span', 'class' => 'hint')),
                        array('HtmlTag', array('tag' => 'li', 
                                               'class' => 'element-group'
                                               ))
                  ));

         $email = new Zend_Form_Element_Text('email');
         $email->setLabel('e-mail: ')
               ->setAttrib('class', 'field profileEmail')
               ->setAttrib('onkeyup','checkEmail(this);')
               ->setAttrib('onclick','checkEmail(this);')
               ->setDescription('msgEmail')
               ->setRequired(true)
               ->addValidator('EmailAddress', true)
               ->setDecorators(array(
                        array('ViewHelper', array('helper'=>'formText')),
                        array('Label', array('separator'=>' ', 'class'=>'gray labelfield')),
                        array('Errors'),
                        array('Description', array('tag' => 'span', 'class' => 'hint')),
                        array('HtmlTag', array('tag' => 'li', 
                                               'class' => 'element-group'
                                               ))
               ));            
         
         $language = new Zend_Form_Element_Select('language');
         $language->setLabel('lang')
                  ->setAttrib('class', 'field profileLang NoHints')
                  ->setRequired(true)
                  ->setMultiOptions(array(
                      'it_IT'=>'italian', 
                      'en_EN'=>'english',
                      'es_ES'=>'spanish',
                      'fr_FR'=>'french',
                      'de_DE'=>'german'
                  ))
                  ->setDecorators(array(
                        array('ViewHelper'),
                        array('Label', array('separator'=>' ', 'class'=>'gray labelfield')),
                        array('Errors'),
                        array('HtmlTag', array('tag' => 'li', 
                                               'class' => 'element-group'
                                               ))
                  ));

         $profile_oid = new Zend_Form_Element_Hidden('profile_oid');
         $profile_oid->setDecorators(array('ViewHelper'));
         
         $this->addElements(array(
            $nickname,
            $fullname,
            $email,
            $language,
            $profile_oid
         ));
    }
}
